package leecode

import "strings"

func findWords(words []string) (result []string) {
	var (
		one   = "QWERTYUIOPqwertyuiop"
		two   = "ASDFGHJKLasdfghjkl"
		three = "ZXCVBNMzxcvbnm"
	)
	for _, word := range words {
		var temp string
		flag := 1
		for index, value := range word {
			if index == 0 {
				//判断一下第一个字符出现在哪个数组中
				if find := strings.Contains(one, string(value)); find {
					temp = one
				} else if find := strings.Contains(two, string(value)); find {
					temp = two
				} else {
					temp = three
				}
			}
			//判断后续字符是否为temp上的字符
			if find := strings.Contains(temp, string(value)); !find {
				flag = 0
				break
			}
		}
		if flag == 1 {
			//符合
			result = append(result, word)
		}
	}
	return
}
